package com.demo.config;

import com.coder4j.platform.config.AuthInterceptor;
import com.coder4j.platform.config.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private AuthInterceptor authInterceptor;

    @Resource
    private UserInterceptor userInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/test/**")
                .excludePathPatterns("/authUser/login")
                .excludePathPatterns("/authUser/register")
                .excludePathPatterns("/sysDict/tree")
                .excludePathPatterns("/wechatLink/pageForShow");


        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/test/**")
                .excludePathPatterns("/authUser/login")
                .excludePathPatterns("/authUser/register")
                .excludePathPatterns("/wechatLink/pageForShow")
                .excludePathPatterns("/authResource/userMenu")
                .excludePathPatterns("/sysDict/tree")
                .excludePathPatterns("/trainTask/saveModel")
        ;
    }
}
